Skip to content

Replace react-test-renderer with @testing-library/react (#1995) - #1995

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
export-D122323827
Oct 1, 2026
Merged

meta-codesync[bot] merged 1 commit into
mainfrom
export-D122323827

Conversation

@vzaidman

@vzaidman vzaidman commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

react-test-renderer is deprecated in React 19. This migrates the Fast Refresh integration tests in metro-runtime to testing-library/react over react-dom.

  • MetroFastRefreshMockRuntime loads react-dom/client and testing-library/react/pure while the DevTools hook is aliased to the runtime's global, and exposes render/screen instead of renderer. Tests call cleanupRuntimes() in afterEach because the pure entry point skips auto-cleanup.
  • The test runs under jsdom (adds jest-environment-jsdom). The module system is created with window shadowed as undefined, so the simulated environment still has no window, like React Native.
  • jest.config.js maps react to metro-runtime's copy. In the xplat/js workspace, react-dom@19.3.0 is hoisted to xplat/js/node_modules and would otherwise resolve react@19.0.0, which means two React instances and empty renders.
  • Replaces the react-test-renderer libdef with minimal react-dom/client and testing-library/react/pure declarations in flow-typed/react-testing.js.
  • Updates both lockfiles and adds the new offline-mirror tarballs.

Differential Revision: D122323827

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 29, 2026
@meta-codesync

meta-codesync Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D122323827.

meta-codesync Bot pushed a commit that referenced this pull request Sep 29, 2026
Summary:
Pull Request resolved: #1995

`react-test-renderer` is deprecated in React 19. This migrates the Fast Refresh integration tests in `metro-runtime` to `testing-library/react` over `react-dom`.

- `MetroFastRefreshMockRuntime` loads `react-dom/client` and `testing-library/react/pure` while the DevTools hook is aliased to the runtime's global, and exposes `render`/`screen` instead of `renderer`. Tests call `cleanupRuntimes()` in `afterEach` because the pure entry point skips auto-cleanup.
- The test runs under `jsdom` (adds `jest-environment-jsdom`). The module system is created with `window` shadowed as `undefined`, so the simulated environment still has no window, like React Native.
- `jest.config.js` maps `react` to metro-runtime's copy. In the xplat/js workspace, `react-dom@19.3.0` is hoisted to `xplat/js/node_modules` and would otherwise resolve `react@19.0.0`, which means two React instances and empty renders.
- Replaces the `react-test-renderer` libdef with minimal `react-dom/client` and `testing-library/react/pure` declarations in `flow-typed/react-testing.js`.
- Updates both lockfiles and adds the new offline-mirror tarballs.

Differential Revision: D122323827
@meta-codesync meta-codesync Bot changed the title Replace react-test-renderer with @testing-library/react Replace react-test-renderer with @testing-library/react (#1995) Sep 29, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 29, 2026
Summary:
Pull Request resolved: #1995

`react-test-renderer` is deprecated in React 19. This migrates the Fast Refresh integration tests in `metro-runtime` to `testing-library/react` over `react-dom`.

- `MetroFastRefreshMockRuntime` loads `react-dom/client` and `testing-library/react/pure` while the DevTools hook is aliased to the runtime's global, and exposes `render`/`screen` instead of `renderer`. Tests call `cleanupRuntimes()` in `afterEach` because the pure entry point skips auto-cleanup.
- The test runs under `jsdom` (adds `jest-environment-jsdom`). The module system is created with `window` shadowed as `undefined`, so the simulated environment still has no window, like React Native.
- `jest.config.js` maps `react` to metro-runtime's copy. In the xplat/js workspace, `react-dom@19.3.0` is hoisted to `xplat/js/node_modules` and would otherwise resolve `react@19.0.0`, which means two React instances and empty renders.
- Replaces the `react-test-renderer` libdef with minimal `react-dom/client` and `testing-library/react/pure` declarations in `flow-typed/react-testing.js`.
- Updates both lockfiles and adds the new offline-mirror tarballs.

Differential Revision: D122323827
@meta-codesync
meta-codesync Bot merged commit 26689e0 into main Oct 1, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants